summaryrefslogtreecommitdiff
path: root/app/[lng]/evcp/(evcp)/items-tech/page.tsx
blob: 52ff519d0a63b851e9b124a193dc37feec78375b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as React from "react"
import { type SearchParams } from "@/types/table"

import { getValidFilters } from "@/lib/data-table"
import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"
import { searchParamsCache } from "@/lib/items-tech/validations"
import { getShipbuildingItems, getOffshoreTopItems, getOffshoreHullItems } from "@/lib/items-tech/service"
import { OffshoreTopTable } from "@/lib/items-tech/table/top/offshore-top-table"
import { OffshoreHullTable } from "@/lib/items-tech/table/hull/offshore-hull-table"

// 대소문자 문제 해결 - 실제 파일명에 맞게 import
import { ItemsShipTable } from "@/lib/items-tech/table/ship/Items-ship-table"

interface IndexPageProps {
  searchParams: Promise<SearchParams>
}

export default async function IndexPage({ searchParams }: IndexPageProps) {
  const params = await searchParams
  const search = searchParamsCache.parse(params)
  const validFilters = getValidFilters(search.filters || [])
  
  // URL에서 아이템 타입 가져오기
  const itemType = params.type || "ship"

  return (
    <div>
      {itemType === "ship" && (
        <ItemsShipTable 
          promises={Promise.all([
            getShipbuildingItems({
              ...search,
              filters: validFilters,
            }),
          ]).then(([result]) => result)} 
        />
      )}
      
      {itemType === "top" && (
        <OffshoreTopTable 
          promises={Promise.all([
            getOffshoreTopItems({
              ...search,
              filters: validFilters,
            }),
          ]).then(([result]) => result)} 
        />
      )}
      
      {itemType === "hull" && (
        <OffshoreHullTable 
          promises={Promise.all([
            getOffshoreHullItems({
              ...search,
              filters: validFilters,
            }),
          ]).then(([result]) => result)} 
        />
      )}
    </div>
  )
}